# coding: utf-8

import os
import sys

from ala_classes import TokenType as T, Token
from scanner import PythonScanner

if __name__ == "__main__":
    input_file_name = sys.argv[1]
    output_file_name = sys.argv[2]
    try:
        input_file = open(input_file_name, 'r')
    except IOError:
        print "Error: Can't open file '" + os.path.join(os.getcwd(), input_file_name) + "'"
        sys.exit(1)
    try:
        output_file = open(output_file_name, 'w')
    except IOError:
        print "Error: Can't open file '" + os.path.join(os.getcwd(), output_file_name) + "'"
        sys.exit(1)

    scanner = PythonScanner(input_file)
    tokens = scanner.get_all_tokens()
    output_file.write(" ".join([token.type_string() for token in tokens]))